package com.taxiApp.server.impl;

import com.taxiApp.domain.PassengerDriverLink;
import com.taxiApp.mapper.PassengerDriverMapper;
import com.taxiApp.server.PassengerDriverService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PassengerDriverServiceImpl implements PassengerDriverService {


    @Resource
    PassengerDriverMapper passengerDriverMapper;

    @Override
    public void saveLink(PassengerDriverLink link) throws Exception {

        PassengerDriverLink passengerDriverLink = passengerDriverMapper.selectLink(link);
        if (passengerDriverLink != null) {

            throw new Exception("该司机在行程中！");
        } else {
            passengerDriverMapper.saveLink(link);
        }

    }

    @Override
    public void deleteLink(PassengerDriverLink link) {
        passengerDriverMapper.deleteLink(link);
    }

}
